package com.darwin.darwinSimpleShape
{
	import com.darwin.darwinIsometric.core.Point3D;
	import com.darwin.darwinIsometric.utils.IsoUtils;
	
	import flash.display.Sprite;
	import flash.geom.Point;

	/**
	 * 立方体 
	 * @author vanCopper
	 * 
	 */	
	public class Cube extends Sprite
	{
		public function Cube(fw:int = 64,fh:int=32,height:int = 20,color:uint = 0x0099FF,cAlpha:Number = .5)
		{
			var lineColor:uint = 0x666666;
			
			
			super();
			
//			this.graphics.beginFill(0xEEEEEE,cAlpha);
			this.graphics.beginFill(color&0xEEEEEE,cAlpha);
			this.graphics.lineStyle(2,lineColor,1);
			
			var pt:Point;
			
			pt = IsoUtils.isoToScreen(new Point3D(fw,0,fh));
			this.graphics.moveTo(pt.x,pt.y);
			
			pt = IsoUtils.isoToScreen(new Point3D(fw,0,0));
			this.graphics.lineTo(pt.x,pt.y);
			
			pt = IsoUtils.isoToScreen(new Point3D(fw,-height,0));
			this.graphics.lineTo(pt.x,pt.y);
			
			pt = IsoUtils.isoToScreen(new Point3D(fw,-height,fh));
			this.graphics.lineTo(pt.x,pt.y);
			
			this.graphics.endFill();
			
			/////////////////////////////////
			
			
//			this.graphics.beginFill(0xCCCCCC,cAlpha);
			this.graphics.beginFill(color&0xCCCCCC,cAlpha);
			this.graphics.lineStyle(2,lineColor,1);
			
			pt = IsoUtils.isoToScreen(new Point3D(fw,0,fh));
			this.graphics.moveTo(pt.x,pt.y);
			
			pt = IsoUtils.isoToScreen(new Point3D(0,0,fh));
			this.graphics.lineTo(pt.x,pt.y);
			
			pt = IsoUtils.isoToScreen(new Point3D(0,-height,fh));
			this.graphics.lineTo(pt.x,pt.y);
			
			pt = IsoUtils.isoToScreen(new Point3D(fw,-height,fh));
			this.graphics.lineTo(pt.x,pt.y);
			
			this.graphics.endFill();
			
			//////////////////////////////////////////////
			
			this.graphics.beginFill(color,cAlpha);
			this.graphics.lineStyle(2,lineColor,1);
			
			pt = IsoUtils.isoToScreen(new Point3D(fw,-height,fh));
			this.graphics.moveTo(pt.x,pt.y);
			
			pt = IsoUtils.isoToScreen(new Point3D(0,-height,fh));
			this.graphics.lineTo(pt.x,pt.y);
			
			pt = IsoUtils.isoToScreen(new Point3D(0,-height,0));
			this.graphics.lineTo(pt.x,pt.y);
			
			pt = IsoUtils.isoToScreen(new Point3D(fw,-height,0));
			this.graphics.lineTo(pt.x,pt.y);
			
			this.graphics.endFill();
			
//			this.alpha = 0.3;
			this.graphics.beginFill(0xFF0000,.5);
			this.graphics.drawRect(0,0,fw*2,fh);
			this.graphics.endFill();
		}
	}
}